package com.cf.apiInstance.rest;

import javax.annotation.Resource;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.cf.apiInstance.annotation.ApiLog;
import com.cf.apiInstance.beans.TenderBulletinRequest;
import com.cf.apiInstance.common.bean.ApiResponse;
import com.cf.apiInstance.common.utils.JsonUtils;
import com.cf.apiInstance.service.PrtcService;

/**
 * 公共资源接口api
 * 
 * @author: cf
 * @date: 28 Nov 2018 5:52:50 pm
 * @vesion: 1.0
 */
@RestController
@RequestMapping("/api")
public class PrtcApiController {

	@Resource
	private PrtcService prtcService;

	@ApiLog(description = "推送招标公告")
	@PostMapping(value = "/push/tender_bulletin", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
	@ResponseBody
	public ApiResponse<Object> pushTenderBulletin(@RequestBody String message) throws Exception {
		TenderBulletinRequest request = JsonUtils.toObject(message, TenderBulletinRequest.class);
		prtcService.save(request.getSubmit());
		return ApiResponse.ok();
	}
}
